package fr.upmc.i3s.fuglmeyeranalyser.tools.utils;

import java.io.File;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URISyntaxException;
import java.net.URL;

import fr.upmc.i3s.fuglmeyeranalyser.MainWindow;

public class DirectoriesUtils {

	public static String getExecutingPath() {
		String executingPath = null;
		try {
			URL url = MainWindow.class.getResource("").toURI().toURL();
			executingPath = url.getPath();
			if(url.getProtocol().equals("jar")) {
				executingPath = new File(((JarURLConnection) url.openConnection()).getJarFileURL().getFile()).getParent();
			}
		} catch (IOException e) {
			System.err.println(e);
		} catch (URISyntaxException e) {
			System.err.println(e);
		}
		return executingPath;
	}

}
